package com.qk.filter;

import jakarta.servlet.*;

import java.io.IOException;
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    // 初始化-web服务器启动时执行一次，只执行一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("DemoFilter...init...");
    }
    // 过滤-web服务器每次处理请求时执行一次
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("DemoFilter...doFilter...");
      //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
   // 销毁-web服务器停止时执行一次，只执行一次
    @Override
    public void destroy() {
        System.out.println("DemoFilter...destroy...");
    }

}
